import { Component, ViewChild, OnInit } from '@angular/core';
import { HttpService } from '../service/http.service';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
  providers: [ HttpService ]
})
export class AppComponent implements OnInit{
  @ViewChild("sidenav") sidenav: any;
  title = '';
  now = new Date();

  // 路由列表设置，icon名称参考地址：https://material.io/icons/
  routes:Array<any>;

  constructor(public httpService: HttpService){

  }

  ngOnInit(){
    this.httpService.getData('/api/user/my_user_role').subscribe(data => {
      if(data['role'] == 'admin'){
        this.routes = [
          {"path":"home","icon":"view_list","name":"利润影响表"},
          {'path':'list2',"icon":"view_list","name":"餐饮盈利决策"},
          {'path':'list3',"icon":"view_list","name":"细分市场决策"},
          {'path':'list4',"icon":"view_list","name":"投资决策"},
          {'path':'list5',"icon":"view_list","name":"细分市场决策2"},
          {'path':'admin',"icon":"account_box","name":"用户管理"},
          {"path":"about","icon":"home","name":"关于我们"},
        ]
      }else{
        this.routes = [
          {"path":"home","icon":"view_list","name":"利润影响表"},
          {'path':'list2',"icon":"view_list","name":"餐饮盈利决策"},
          {'path':'list3',"icon":"view_list","name":"细分市场决策"},
          {'path':'list4',"icon":"view_list","name":"投资决策"},
          {'path':'list5',"icon":"view_list","name":"细分市场决策2"},
          {"path":"about","icon":"home","name":"关于我们"},
        ]
      }
    })

    
  }
}
